package ToYesterday.Day11_chalk_que;

import org.junit.Test;

public class SolutionChalk {
    @Test
    public void test(){
        int [] chalk = {5,1,5};
        System.out.println(chalkReplacer(chalk,22));
    }

    public int chalkReplacer(int[] chalk, int k) {
        int i =0;
        int last=k;
//        while ((last=(last-chalk[i]))>=0){
//            i++;
//            if (i==chalk.length)i=0;
//        }
        for (i =0;i<=chalk.length;i++){
            if (i==chalk.length)i=0;
            last = last-chalk[i];
            if (last<0)return i;
        }
        return i;
    }
}
